﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace StuClassInfo
{
    public class Dbhelper
    {
        //声明数据库连接字段
        private readonly static string strcon = ConfigurationManager.ConnectionStrings["StuUseConnectionString"].ConnectionString;

        #region 离线式数据查询返回DataTable
        /// <summary>
        /// 离线式数据查询返回DataTable
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="parm"></param>
        /// <returns></returns>
        public static DataTable datatable(string sql)
        {
            using (SqlDataAdapter sda = new SqlDataAdapter(sql, strcon))
            {
                DataTable dt = new DataTable();
                sda.Fill(dt);
                return dt;
            }
        }
        #endregion
    }
}